//==========================================================================
// Copyright (c) 2000-2006,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#if !defined(__RGB2YCBCRCONVERTER_H_)
#define __RGB2YCBCRCONVERTER_H_

class RGB2YCbCrConverter
{
private:
    int          *m_piConvertTable;

    BYTE         *m_pRGBWorkBuf; // work buffer, link input RGB buffer and YCbCr buffer to change data

    int           m_iDigitalZoom;

    unsigned long m_ulDesWidth;
    unsigned long m_ulDesHeight;

    unsigned long m_ulSrcWidth;
    unsigned long m_ulSrcHeight;
    unsigned int  m_uSrcPixelBytes;//reserved

    HANDLE        m_hLock;

private:
    int          *BuildRGB2YCbCrConvertTable();

    void          SrcZoomToWork(BYTE *pSrcBuf);

    void          WorkTo422R90(YCbCrBufferInfo YCbCrBuffer);

    void          WorkTo422(YCbCrBufferInfo YCbCrBuffer);

public:
    BOOL          Initialize();

    void          Destroy();

    void          SetDigitalZoom(int zoom);

    void          GetDigitalZoom(int *pZoom);

    BOOL          SetSrcFormat(unsigned long SrcWidth,
                               unsigned long SrcHeight,
                               unsigned int  SrcPixelBs);//reserved

    BOOL          SetDesFormat(unsigned long DesWidth,
                                 unsigned long DesHeight);

    BOOL          RGBTo422Rotary90(BYTE *pRGBSrcBuffer,
                                 YCbCrBufferInfo YCbCrBuffer);

    BOOL          RGBTo422Normal(BYTE *pRGBSrcBuffer,
                        YCbCrBufferInfo YCbCrBuffer);
};

#endif //__RGB2YCBCRCONVERTER_H_
